package com.fastCms.customer.frame.controller;


import com.fastCms.business.frame.pojo.PageParam;
import com.fastCms.business.frame.pojo.po.*;
import com.fastCms.business.frame.pojo.vo.AlbumContentVO;
import com.fastCms.business.frame.pojo.vo.AlbumVO;
import com.fastCms.business.frame.response.ApiResponse;
import com.fastCms.business.frame.response.ResponseUtil;
import com.fastCms.business.frame.service.AlbumContentService;
import com.fastCms.business.frame.service.AlbumService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("api/album")
@Api(value = "ApiAlbumController", tags = "C端-相册管理")
public class ApiAlbumController {
    @Resource
    private AlbumService albumServiceImpl;
    @Resource
    private AlbumContentService albumContentServiceImpl;

    @PostMapping("/showPage")
    @ApiOperation(value = "相册-分页", notes = "")
    public ApiResponse<PageInfo<AlbumVO>> showPage(@RequestBody PageParam<AlbumQueryPO> param) {
        PageInfo<AlbumVO> result = albumServiceImpl.showPage(param);
        return ResponseUtil.success(result);
    }

    @PostMapping("/albumSaveOrUpdate")
    @ApiOperation(value = "相册-创建或更新", notes = "")
    public ApiResponse<Boolean> albumSaveOrUpdate(@RequestBody AlbumSaveOrUpdatePO param) {
        Boolean result = albumServiceImpl.albumSaveOrUpdate(param);
        return ResponseUtil.success(result);
    }

    @PostMapping("/albumSort")
    @ApiOperation(value = "相册-排序", notes = "")
    public ApiResponse<Boolean> albumSort(@RequestBody List<SortPO> param) {
        Boolean result = albumServiceImpl.albumSort(param);
        return ResponseUtil.success(result);
    }

    @PostMapping("/albumDelete")
    @ApiOperation(value = "相册-删除", notes = "")
    public ApiResponse<Boolean> albumDelete(@RequestBody IdStrPO idStrPO) {
        Boolean result = albumServiceImpl.albumDelete(idStrPO.getId());
        return ResponseUtil.success(result);
    }

    @PostMapping("/contentPage")
    @ApiOperation(value = "内容-分页", notes = "内容列表")
    public ApiResponse<PageInfo<AlbumContentVO>> contentPage(@RequestBody PageParam<AlbumContentQueryPO> param) {
        PageInfo<AlbumContentVO> result = albumContentServiceImpl.contentPage(param);
        return ResponseUtil.success(result);
    }

    @PostMapping("/contentDelete")
    @ApiOperation(value = "内容-删除", notes = "内容删除")
    public ApiResponse<Boolean> contentDelete(@RequestBody IdStrPO idStrPO) {
        Boolean result = albumContentServiceImpl.contentDelete(idStrPO.getId());
        return ResponseUtil.success(result);
    }

    @PostMapping("/contentAdd")
    @ApiOperation(value = "内容-添加", notes = "添加")
    public ApiResponse<Boolean> contentAdd(@RequestBody AlbumContentSavePO param) {
        Boolean result = albumContentServiceImpl.contentAdd(param);
        return ResponseUtil.success(result);
    }

}

